import { password_special_static } from '@/utils/mixins/res/index'

/**
 * 全局秘密输入框校检
 * @param {*} str value值
 * @param {String} oper_from 当前 form 表单的字段， 例如 'from.password' 只能有一个 . ,约定条件
 * @returns 
 */
let password_input = function (str, oper_from) {
  let a = `a-zA-Z0-9${password_special_static}`
  let reg = new RegExp(`[^${a}]`, 'g');
  let v = str.replace(reg, '').trim()
  if (oper_from) {
    let arr = oper_from.split('.')
    if (arr.length === 2) {
      this[arr[0]][arr[1]] = v
    } else {
      this[arr[0]] = v
    }
  }
  return v
}

export let password_input_static = {
  methods: {
    password_input_static: password_input
  },
}


export default {
  data() { },
  methods: {
    password_input_static: password_input
  },
}
